﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;

namespace PerCiGal.Common
{
    public class FunctionXML
    {
        public static object StringToXML(System.Type tipo, string testo)
        {
            var mySerializer = new System.Xml.Serialization.XmlSerializer(tipo);
            return mySerializer.Deserialize(new StringReader(testo));
        }

        public static string ObjectToXMLString(System.Type tipo, object oggetto)
        {
            var output = new StringWriter(new System.Text.StringBuilder());
            var serializer = new System.Xml.Serialization.XmlSerializer(tipo);
            serializer.Serialize(output, oggetto);

            return output.ToString();
        }
    }
}
